package day04;

import java.util.Scanner;

public class GuessDemo {
    public static void main(String[] args) {
        /*
        Scanner scan = new Scanner(System.in);
        int num = (int)(Math.random()*1000+1); //原始数据，此处可改为动态变动的随机数。1-1000

        System.out.println("猜吧！");
        int guess = scan.nextInt();
        while(guess != num){
            if (guess < num) {
                System.out.println("猜小了，继续吧！");
            }else{
                System.out.println("猜大了，继续吧！");
            }
            guess = scan.nextInt();
        }
        System.out.println("恭喜你猜对了！");
        */

        //自造死循环
        Scanner scan = new Scanner(System.in);
        int num = 500; //原始数据，此处可改为动态变动的随机数。1-1000

        while (true) {
            System.out.println("猜吧！");
            int guess = scan.nextInt();
                if (guess < num) {
                    System.out.println("猜小了，继续吧！");
                } else if(guess > num){
                    System.out.println("猜大了，继续吧！");
                }else{
                    System.out.println("猜对了，恭喜你！");
                    break;
            }
            }
    }
}
